from common.config import commonConfig as Config
from toolsSrc.dbtools.dbtools import DBTools
from sqlalchemy import text

def getDBData1():
    url = Config.url
    # url = 'mysql+pymysql://root:123456@localhost:3306/eladmin?charset=utf8'
    session = DBTools(url).connectDB()
    result = session.execute(
        text("select * from data1"))
    print(result.all())
    session.commit()
    session.close()
    return result

def getWindSpeedFromDBData1():
    url = Config.url
    # url = 'mysql+pymysql://root:123456@localhost:3306/eladmin?charset=utf8'
    session = DBTools(url).connectDB()
    sqlStr = "select `" + Config.WindSpeed + "` from data1"
    result = session.execute( text(sqlStr) )
    session.commit()
    session.close()
    windSpeed = result.all()[0][0]
    return windSpeed

if __name__ == '__main__':
    # getDBData1()
    getWindSpeedFromDBData1()
